//相当于body的onload方法
//在页面全部加载之后，才会执行这个方法
$(document).ready(function(){
	$("#loginBtn").click(function(){
		if($("#userNameId").val() == ''){
			$("#userNameId").tooltip('show','请输入用户名');
			return;
		}
		if($("#passwdId").val() == ''){
			$("#passwdId").tooltip('show','请输入密码');
			return;
		}
		$(this).button('loading');
		var loginUrl = adminQueryUrl + adminUserService;
		var param = "action=login";
		param += "&username="+$("#userNameId").val();
		param += "&upwd="+$("#passwdId").val();
		console.log('loginUrl='+loginUrl);
		console.log('param='+param);
		var token = '1';
		var userId = '2';
		$.ajax({
			url:loginUrl,
			type:'post',
			beforeSend:function(xhr){
				xhr.setRequestHeader("token",token);
				xhr.setRequestHeader("userId",userId);
			},
			header:{"token":token,"userId":userId},
			data:param,
			dataType:'text',
			success:function(result){
				$("#loginBtn").button('reset');
				if (result=='1'){
					location.href = $("#contextPath").val()+"/admin/admin.jsp";
				}
				else {
					new $.zui.Messager('用户名或者密码错误!', {
						placement:'center',
					    type: 'warning' // 定义颜色主题
					}).show();
				}
			},
			error:function(result){
				new $.zui.Messager('系统繁忙,请稍候再试!', {
					placement:'center',
				    type: 'warning' // 定义颜色主题
				}).show();
			}
		});
	});
});
function login1(){
	alert(2);
}
var login = function(){
	alert('login');
}